import { createParamDecorator, ExecutionContext } from '@nestjs/common';

export const CurrentUser = createParamDecorator((data: string, ctx: ExecutionContext) => {
  const request = ctx.switchToHttp().getRequest();
  
  if (data && request.user) {

    return request.user[data];
  } else {
    return request.user;
  }
});

